package ru.cod.rs.objects.gameobjects;

import ru.cod.rs.interfaces.Game;
import ru.cod.rs.interfaces.gameInterface.Unit;
import android.graphics.Bitmap;

public abstract class AbstractUnit implements Unit {
	protected Side side;
	protected int x, y;
	protected Bitmap image;
	protected Game game;

	protected int width, height;

	public AbstractUnit(Side side, Game g) {
		this.side = side;
		game = g;
		setImage();
		x = side.equals(Side.ENEMY) ? game.getGraphics().getWidth()
				- getWidth() : 0;
		y = game.getGraphics().getHeight() - getHeight() - 1;

	}

	@Override
	public abstract void update();

	@Override
	public void render() {
		game.getGraphics().drawBitmap(image, x, y);
	}

	public int getWidth() {
		return image.getWidth();
	}

	public int getHeight() {
		return image.getHeight();
	}

	protected abstract void setImage();

	/**
	 * @return the side
	 */
	public Side getSide() {
		return side;
	}

	/**
	 * @param side
	 *            the side to set
	 */
	public void setSide(Side side) {
		this.side = side;
	}

	/**
	 * @return the x
	 */
	public int getX() {
		return x;
	}

	/**
	 * @param x
	 *            the x to set
	 */
	public void setX(int x) {
		this.x = x;
	}

	/**
	 * @return the y
	 */
	public int getY() {
		return y;
	}

	/**
	 * @param y
	 *            the y to set
	 */
	public void setY(int y) {
		this.y = y;
	}

	/**
	 * @param width
	 *            the width to set
	 */
	public void setWidth(int width) {
		this.width = width;
	}

	/**
	 * @param height
	 *            the height to set
	 */
	public void setHeight(int height) {
		this.height = height;
	}
}
